package com.example.test4.model

import android.os.Parcel
import android.os.Parcelable

class User() : Parcelable {
    var name: String = "卢政宇"
    var phone: String = "110"
    var gender: String = "男"
    var hobbies: String = "喜欢小郭"
    var mail: String = "输入邮箱"
    var score: Int = 0
    var photoPath: String? = null // 新增照片路径字段

    constructor(parcel: Parcel) : this() {
        name = parcel.readString() ?: "卢政宇"
        phone = parcel.readString() ?: "110"
        gender = parcel.readString() ?: "男"
        hobbies = parcel.readString() ?: "喜欢小郭"
        mail = parcel.readString() ?: "输入邮箱"
        score = parcel.readInt()
        photoPath = parcel.readString() // 读取路径
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(name)
        parcel.writeString(phone)
        parcel.writeString(gender)
        parcel.writeString(hobbies)
        parcel.writeString(mail)
        parcel.writeInt(score)
        parcel.writeString(photoPath) // 写入路径
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<User> {
        override fun createFromParcel(parcel: Parcel): User {
            return User(parcel)
        }

        override fun newArray(size: Int): Array<User?> {
            return arrayOfNulls(size)
        }
    }
}